<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>白名单</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/layuiadmin/style/admin.css" media="all">
</head>
<body>

<div class="layui-card layadmin-header">
    <div class="layui-breadcrumb" lay-filter="breadcrumb">
        <a lay-href="">主页</a>
        <a><cite>组件</cite></a>
        <a><cite>数据表格</cite></a>
        <a><cite>开启分页</cite></a>
    </div>
</div>

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">申请列表</div>
                <div class="layui-card-body">
                    <a href="/user/export">用户导出</a>
                    <button class="layui-btn layui-btn-primary" id="exportBtn">用户导入</button>
                </div>
            </div>
        </div>
    </div>
</div>
<div id="exportdiv" style="display: none;padding: 20px">
    <div class="layui-upload-drag" id="test10">
        <i class="layui-icon"></i>
        <p>点击上传，或将文件拖拽到此处</p>
        <div class="layui-hide" id="uploadDemoView">

        </div>
    </div>
    <div id="mmmm">
        <span id="msg"></span>
    </div>
</div>
<script src="/layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: '/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'table', 'laydate',"layer", 'upload'], function () {
        var admin = layui.admin
            , table = layui.table,
            upload = layui.upload,
            layer = layui.layer,
            form = layui.form,
            $ = layui.$,
            laydate = layui.laydate
            $("#exportBtn").click(function () {
                layer.open({
                    type: 1,
                    content: $("#exportdiv")
                })
            })
        //拖拽上传接口
        upload.render({
            elem: '#test10',
            accept: 'file'
            ,url: '/user/import' //此处用的是第三方的 http 请求演示，实际使用时改成您自己的上传接口即可。
            ,done: function(res){
               // layer.msg('上传成功');
                if(res.data.status){
                    $("#msg").text("导入成功，修改"+res.data.update+"人，添加"+res.data.insert+"人")
                }else{
                    $("#msg").text(res.data.errorMsg)
                    $(res.data.errorData).each(function (index, item) {
                       var $new = $("<span>"+item.errorMsg+"</span>")
                        $("#mmmm").append($new)
                    })
                }
                console.log(res)
            }
        });
    });
</script>
</body>
</html>